﻿/*
 * @file: ShippingDetailsBLL.cs
 * @in namespace: BLL
 */
using System;
using DAL;

/// <summary>
/// Summary description for ShippingDetailsBLL
/// </summary>
namespace BLL
{
    public class ShippingDetailsBLL
    {
        public ShippingDetailsBLL()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        #region IShippingDetails Members

        /// <summary>
        /// GetShippingByShippingID
        /// </summary>
        /// <param name="shippingID">Shipping ID</param>
        /// <param name="allowFilter">"true" if allow ignore hidden record</param>
        /// <returns>Record corresponding</returns>
        public static ShippingDetails GetShippingByOrderID(int orderID)
        {
            try
            {
                return DataAccessHelper.GetShippingDetailsDA().GetShippingByOrderID(orderID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// GetShippingByBillID
        /// </summary>
        /// <param name="billID">Bill ID</param>
        /// <param name="allowFilter">"true" if allow ignore hidden record</param>
        /// <returns>Record corresponding</returns>
        //public static ShippingDetails GetShippingByBillID(int billID, bool allowFilter)
        //{
        //    try
        //    {
        //        return DataAccessHelper.GetShippingDetailsDA().GetShippingByBillID(billID, allowFilter);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        /// <summary>
        /// GetShippingByUserID
        /// </summary>
        /// <param name="userID">User ID</param>
        /// <param name="allowFilter">"true" if allow ignore hidden record</param>
        /// <returns>Records corresponding</returns>
        //public static ShippingDetails[] GetShippingByUserID(int userID, bool allowFilter)
        //{
        //    try
        //    {
        //        return DataAccessHelper.GetShippingDetailsDA().GetShippingByUserID(userID, allowFilter);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        /// <summary>
        /// InsertShippingDetails
        /// </summary>
        /// <param name="shippingDetails">ShippingDetails entity</param>
        /// <param name="autoNumber">Current ShippingID inserted(output)</param>
        /// <returns>1 if successful, 0 if error occurred</returns>
        public static int InsertShippingDetails(ShippingDetails shippingDetails, out int autoNumber)
        {
            try
            {
                if (shippingDetails.OrderID == 0)
                    throw new OnlineFloralDeliveryException(2, "OrderID is not allow null or empty");
                else if (shippingDetails.Name == null || shippingDetails.Name.Length == 0)
                    throw new OnlineFloralDeliveryException(2, "Name is not allow null or empty");
                else if (shippingDetails.Address == null || shippingDetails.Address.Length == 0)
                    throw new OnlineFloralDeliveryException(2, "Address is not allow null or empty");
                else if (shippingDetails.DeliveryDate == null)
                    throw new OnlineFloralDeliveryException(2, "DeliveryDate is not allow null or empty");
                return DataAccessHelper.GetShippingDetailsDA().InsertShippingDetails(shippingDetails, out autoNumber);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// DisableShipping
        /// </summary>
        /// <param name="shippingID">Shipping ID</param>
        /// <param name="isEnable">"true" if allow enable ShippingDetails, "false" if allow hidden ShippingDetails</param>
        /// <returns>1 if successful, 0 if error occurred</returns>
        //public static int DisableShipping(int shippingID, bool isEnable)
        //{
        //    try
        //    {
        //        return DataAccessHelper.GetShippingDetailsDA().DisableShipping(shippingID, isEnable);
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}

        #endregion
    }
}